package com.coolsummer.limiter;

import com.coolsummer.abstracts.Limiter;
import com.coolsummer.enums.LimiterEnum;

/**
 * @author coolsummer
 * @describe 限流器工厂类
 * @date 2019/11/19 17:47
 */
public class LimiterFactory {

    public static Limiter create(LimiterEnum limiterEnum,int qps){
        switch (limiterEnum){
            case COUNT_LIMITER:
                return new CountLimiter(qps);
            case LEAKY_BUCKET_LIMITER:
                return new LeakyBucketLimiter(qps);
            case TOKEN_LIMITER:
                return new TokenLimiter(qps);
            case GUAVA_LIMITER:
                return new GuavaLimiter(qps);
            default:
                return null;
        }
    }
}
